// import axios from 'axios'
import OpenAI from 'openai'
// import { Role } from '../models/novel'

const openai = new OpenAI({
  // 若没有配置环境变量，请用百炼API Key将下行替换为：apiKey: "sk-xxx",
  apiKey: 'e14a7c57-9d03-44b3-9979-3bef6fadb23a',
  baseURL: 'https://ark.cn-beijing.volces.com/api/v3',
})

export function getImageFaceInfo({ url, text }) {
  return new Promise((resolve) => {
    openai.chat.completions
      .create({
        model: 'ep-20250102175958-vslpq',
        messages: [
          {
            role: 'user',
            content: [
              {
                type: 'text',
                text,
              },
              {
                type: 'image_url',
                image_url: {
                  url: url,
                },
              },
            ],
          },
        ],
      })
      .then((completion) => {
        resolve(completion.choices[0])
      })
      .catch((error) => {
        resolve(error)
      })
  })
}
